"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var http_1 = require("@angular/http");
var api_1 = require("../../../config/api");
var CouponService = /** @class */ (function () {
    function CouponService(httpService) {
        this.httpService = httpService;
    }
    // 获取卡券列表
    CouponService.prototype.getCouponList = function (page, pageSize, keyword) {
        var url = api_1.adSystemApiUrl + "/v2/member/card_coupons/list";
        var headers = new http_1.Headers({ 'Content-Type': 'application/json' });
        var options = new http_1.RequestOptions({ headers: headers });
        var body = JSON.stringify({
            page: page,
            pageSize: pageSize,
            keyword: keyword
        });
        return this.httpService.httpPostAuth(url, body, options).map(function (rs) { return rs; });
    };
    // 获取Tag列表页
    CouponService.prototype.getTagList = function (name) {
        var url = api_1.adSystemApiUrl + "/v2/member/card_coupons_tag/get_all";
        var headers = new http_1.Headers({ 'Content-Type': 'application/json' });
        var options = new http_1.RequestOptions({ headers: headers });
        var body = { name: name };
        return this.httpService.httpPostAuth(url, body, options).map(function (rs) { return rs; });
    };
    // 通过Tag获取卡券类型
    CouponService.prototype.getCouponListByTag = function (card_coupons_tag_uuid) {
        var url = api_1.adSystemApiUrl + "/v2/member/card_coupons/get_card_coupons_list_by_tag";
        var headers = new http_1.Headers({ 'Content-Type': 'application/json' });
        var options = new http_1.RequestOptions({ headers: headers });
        var body = JSON.stringify({ card_coupons_tag_uuid: card_coupons_tag_uuid });
        return this.httpService.httpPostAuth(url, body, options).map(function (rs) { return rs; });
    };
    // 删除卡券
    CouponService.prototype.delCoupon = function (id) {
        var url = api_1.adSystemApiUrl + "/v2/member/card_coupons/" + id + "/del";
        var headers = new http_1.Headers({ 'Content-Type': 'application/json' });
        var options = new http_1.RequestOptions({ headers: headers });
        var body = JSON.stringify({});
        return this.httpService.httpPostAuth(url, body, options).map(function (rs) { return rs; });
    };
    // 删除卡券Tag
    CouponService.prototype.delCardTag = function (card_coupons_uuid, card_coupons_tag_uuid) {
        var url = api_1.adSystemApiUrl + "/v2/member/card_coupons/card_coupons_tag_unbinding";
        var headers = new http_1.Headers({ 'Content-Type': 'application/json' });
        var options = new http_1.RequestOptions({ headers: headers });
        var body = JSON.stringify({
            card_coupons_uuid: card_coupons_uuid,
            card_coupons_tag_uuid: card_coupons_tag_uuid
        });
        return this.httpService.httpPostAuth(url, body, options).map(function (rs) { return rs; });
    };
    // 批量绑定卡券Tag
    CouponService.prototype.batchCardBinding = function (card_coupons_tag_uuid, card_coupons_uuid_json) {
        var url = api_1.adSystemApiUrl + "/v2/member/card_coupons/batch_card_coupons_tag_binding";
        var headers = new http_1.Headers({ 'Content-Type': 'application/json' });
        var options = new http_1.RequestOptions({ headers: headers });
        var body = JSON.stringify({
            card_coupons_tag_uuid: card_coupons_tag_uuid,
            card_coupons_uuid_json: JSON.stringify(card_coupons_uuid_json)
        });
        return this.httpService.httpPostAuth(url, body, options).map(function (rs) { return rs; });
    };
    // 获取店铺商品类型列表
    CouponService.prototype.getGroupList = function () {
        var url = api_1.adSystemApiUrl + "/v1/member/applet_goods_category/list";
        return this.httpService.httpGetAuth(url).map(function (rs) { return rs; });
    };
    // 获取商品列表
    CouponService.prototype.getGoodsList = function (page, pageSize, applet_goods_category_id, keyword) {
        var _applet_goods_category_id = applet_goods_category_id || '', _keyword = keyword || '';
        var url = api_1.adSystemApiUrl + "/v1/member/goods/list" +
            ("?applet_goods_category_id=" + _applet_goods_category_id) +
            ("&keyword=" + _keyword + "&page=" + page + "&pageSize=" + pageSize);
        return this.httpService.httpGetAuth(url).map(function (rs) { return rs; });
    };
    // 新增卡券
    CouponService.prototype.addCoupon = function (data) {
        var url = api_1.adSystemApiUrl + "/v2/member/card_coupons/add";
        var headers = new http_1.Headers({ 'Content-Type': 'application/json' });
        var options = new http_1.RequestOptions({ headers: headers });
        var body = JSON.stringify(data);
        return this.httpService.httpPostAuth(url, body, options).map(function (rs) { return rs; });
    };
    // 编辑卡券
    CouponService.prototype.editCoupon = function (id, condition_receive_quantity, relation_id_json) {
        var url = api_1.adSystemApiUrl + "/v2/member/card_coupons/" + id + "/edit_part";
        var headers = new http_1.Headers({ 'Content-Type': 'application/json' });
        var options = new http_1.RequestOptions({ headers: headers });
        var body = JSON.stringify({
            condition_receive_quantity: condition_receive_quantity,
            relation_id_json: relation_id_json
        });
        return this.httpService.httpPostAuth(url, body, options).map(function (rs) { return rs; });
    };
    // 获取卡券详情
    CouponService.prototype.getCouponDetail = function (id) {
        var url = api_1.adSystemApiUrl + "/v2/member/card_coupons/" + id + "/info";
        var headers = new http_1.Headers({ 'Content-Type': 'application/json' });
        var options = new http_1.RequestOptions({ headers: headers });
        var body = JSON.stringify({});
        return this.httpService.httpPostAuth(url, body, options).map(function (rs) { return rs; });
    };
    // 获取商品详情
    CouponService.prototype.getGoodsDetail = function (id) {
        var url = api_1.adSystemApiUrl + "/v1/applet/goods/get_goods_info?id=" + id;
        return this.httpService.httpGetAuth(url).map(function (rs) { return rs; });
    };
    // 获取小程序详情
    CouponService.prototype.getAppletInfo = function () {
        var url = api_1.adSystemApiUrl + "/v1/member/applets/applet_detail";
        return this.httpService.httpGetAuth(url).map(function (rs) { return rs; });
    };
    // 申请开通卡券
    CouponService.prototype.applyCoupon = function (appletName, applet_uuid) {
        var url = api_1.adSystemApiUrl + "/v2/member/account/apply_merchant_key_post";
        var headers = new http_1.Headers({ 'Content-Type': 'application/json' });
        var options = new http_1.RequestOptions({ headers: headers });
        var body = JSON.stringify({
            name: appletName,
            tp_id: applet_uuid,
            tp_type: api_1.tpType
        });
        return this.httpService.httpPostAuth(url, body, options).map(function (rs) { return rs; });
    };
    CouponService = __decorate([
        core_1.Injectable()
    ], CouponService);
    return CouponService;
}());
exports.CouponService = CouponService;
